package test
{
	import flash.display.Bitmap;
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Transform;
	import flash.net.URLRequest;
	
	import slices.BlankTime;
	import slices.FadeInDisplayObject;
	import slices.FadeOutDisplayObject;
	import slices.TimeSlice;
	import globals.$athena;
	
	import slices.TransformColor;
	
	[SWF(width="1280", height="720", backgroundColor="0xFFFFFF")]
	
	public class ProfileTest extends Sprite
	{
		public var loader:Loader = new Loader();
		public var profiles:Vector.<Bitmap>;
		
		public function ProfileTest()
		{
			super();			
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.load(new URLRequest("../asset/flash/Profile2.swf"));
			$athena.start(stage);
		}
		
		public function onComplete(e:Event):void {
			var mc:MovieClip = loader.content as MovieClip;
			var dis:DisplayObject;
			var i:int = 0;
			profiles = new Vector.<Bitmap>(mc.numChildren);
			while (mc.numChildren != 0) {
				dis = mc.removeChildAt(0);
				dis.alpha = 0;
				addChild(dis);
				profiles[i] = dis as Bitmap;				
				i++;
			}
//			var ts:TimeSlice;
//			var fadeIn:FadeInDisplayObject;
//			var fadeOut:FadeOutDisplayObject;
//			var blank:BlankTime = new BlankTime(0);
//			var first:BlankTime = blank;
//			var j:int;
//			for (i = 0; i < profiles.length; i++) {
//				fadeIn = new FadeInDisplayObject(profiles[i], 0.04);
//				j = (i-1+profiles.length)%profiles.length;
//				fadeOut = new FadeOutDisplayObject(profiles[j], 0.05);
//				blank.appendNext(fadeIn);
//				blank.appendNext(fadeOut);
//				blank = new BlankTime(2000);
//				fadeIn.appendNext(blank);
//			}
//			blank.appendNext(first);
//			$athena.addTimeSlice(first);			
//			addChild(profiles[0]);
			var bmp:Bitmap = profiles[0];
			bmp.alpha = 1;
			
//			bmp.x += bmp.width; 	
//			bmp.scaleX = -1;
			var m:Matrix=  new Matrix(-1, 0, 0, 1, bmp.width);
			bmp.transform.matrix = m; 
			
			var cm:ColorTransform = new ColorTransform(0.4, 0.4, 0.4);
			var cm2:ColorTransform = new ColorTransform(1, 1, 1);
			var tc:TransformColor = new TransformColor(bmp, cm2, 200);
			bmp.transform.colorTransform = cm;
			var blank:BlankTime = new BlankTime(1000);
			blank.appendNext(tc);
			$athena.addTimeSlice(blank);
		}
		
		
	}
}